home *** CD-ROM | disk | FTP | other *** search
-
- This documentation file describes a batch file called MOVE.BAT. There is
- no accompanying "program" file as it is contained within.
-
- While developing a program, I often found myself moving files from one
- directory to another. Since DOS does not have a "move" command, I was using
- the commands "copy" and "del" as follows:
-
- COPY filespec destination
- DEL filespec
-
- For example:
-
- COPY myfile \work\prog
- DEL myfile
-
- As you can imagine, this got tiresome after a while. Batch files to the
- rescue! I wrote a very simple batch file called MOVE.BAT consisting of the
- commands
-
- COPY %1 %2
- DEL %1
-
- which is just a generalization of the commands above. The example given above
- would be entered as:
-
- MOVE myfile \work\prog
-
- which seems like a logical solution to the problem. There are, however, some
- hidden hazards in doing this.
-
- If DOS cannot copy your file for some reason, the "copy" command will fail
- and the next command, "del", is executed. Your file will be deleted and the
- (possibly only!) original copy is gone! Common causes of this would be a
- destination file marked read only or a full disk/directory. In this case I
- recommend you have a copy of Peter Norton's UNERASE utility handy.
-
- One might be tempted to solve this problem by using the IF EXIST batch sub-
- command of DOS 2.0:
-
- COPY %1 %2
- if exist %2\%1 DEL %1
-
- This method first checks to make sure that the destination file exists before
- deleting the source file. Alas, path names are not allowed with "if exist"
- (see DOS 2.0 manual, page 6-41) and so this would be useful only for files in
- the current directory (the net effect would be the same as "rename"). The
- first (and simpler) version of move works with paths for both the source and
- destination.
-
- If you specify a nonexistant (misspelled?) directory name as the second
- argument to MOVE, DOS simply creates the destination file in the current
- working directory. If you specify a nonexistant source file, DOS complains,
- but no harm is done.
-
- MOVE will probably be most useful if you have a hard disk but is equally
- useable for floppies. The more directories you have, the more useful it will
- be. The global filename templates "*" and "?" work fine with MOVE and enhance
- its power. I keep MOVE.BAT in my \DOS directory with all the other DOS commands
- and have that directory on my "path" so I can use it just like any other DOS
- command anywhere in my system.
-
- This "program" has been submitted for publication in PC-WORLD's *.* column.
-
- Tony Alan Rhea
- 1030 Ivy Lane
- Cary, NC 27511
- (919) 467-7143
-